var dataDetail = null;

;layui.define(function(e) {
    layui.use(['table','layer','form','laydate','util'], function(){
        var $ = layui.$
            ,layer = layui.layer
            ,form = layui.form
            ,table = layui.table
            ,laydate = layui.laydate;
        //展示已知数据
        table.render({
            elem: '#idTable'
            ,id: 'listReload'
            ,url: hostUrl+'/broke/withdraw/list'
            ,cellMinWidth: 180
            ,loading: true
            ,cols: [[ //标题栏
                {field: 'broker_name', title: '经纪人姓名', minWidth: 110}
                ,{field: 'broker_account', title: '手机号', minWidth: 130}
                ,{field: 'referralName', title: '绑定企业'}
                ,{field: 'withdraw_amount', title: '提现金额(元)', minWidth: 110}
                ,{field: 'create_time', title: '提现时间', minWidth: 180,templet: function(d){
                	return layui.util.toDateString(d.create_time, 'yyyy-MM-dd HH:mm:ss');
                }}
                ,{field: 'referralName', title: '类型', minWidth: 110,templet: function(d){
                	if(d.referralName == null || d.referralName == ''){
                		return "独立经纪人";
                	}else{
                		return "企业经纪人";
                	}
                }}
                ,{field: 'withdraw_amount_status', title: '状态', minWidth: 110,templet: function(d){
                	if(d.withdraw_amount_status == '1'){
                		return "已到账";
                	}else if(d.withdraw_amount_status == '2'){
                		return "处理中";
                	}else if(d.withdraw_amount_status == '3'){
                		return "账户余额不足";
                	}else if(d.withdraw_amount_status == '4'){
                		return "今日提现额度上限";
                	}else if(d.withdraw_amount_status == '9'){
                		return "提现失败";
                	}else{
                		return "-";
                	}
                }}
                ,{field: 'error_info', title: '失败原因', minWidth: 200}
            ]]
            ,page: true //是否显示分页
        });
       
        form.on('select(selectStore)', function(data){
        	selectStore();
        });
        
        //监听工具条
//        table.on('tool(listTable)', function(obj){
//            var data = obj.data;
//            if(obj.event === 'detail'){
//            	dataDetail=data;
//            	var detail=layer.open({
//                    type: 2
//                    ,id: (new Date()).valueOf()
//                    ,title: '详情'
//                    ,content: hostUrl+'/broker/rakeBack/detail.do'
//                    ,area:  ['500px', '500px']
//                    ,maxmin: true
//                    ,end: function(){
//                    	dataDetail=null;
//                    }
//                }); 
//            	layer.full(detail); 
//            }
//        });
        
        $("#inputOptions").click(function () {
		    return window.location.href=hostUrl+"/broke/withdraw/dowExcel?accName="+$("#accName").val()+"&account="+$("#account").val()+"&status="+$("#status").val();
        })
        //表刷新方法
        var reloadTable = function () {
            table.reload("listReload", { //此处是上文提到的 初始化标识id
                where: {
                	accName: $("#accName").val(),
                	account: $("#account").val(),
                	status: $("#status").val()
                }
            });
        };
        $("#search-button").on("click",function () {
            reloadTable();
        })
    });
});